// Copyright (c) MatrixFramework. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System.Threading;
using System.Threading.Tasks;

namespace Matrix.ServiceCommunication.Services;

/// <summary>
/// 认证提供者接口
/// </summary>
public interface IAuthenticationProvider
{
    /// <summary>
    /// 获取访问令牌
    /// </summary>
    /// <param name="serviceName">服务名称</param>
    /// <param name="cancellationToken">取消令牌</param>
    /// <returns>访问令牌</returns>
    Task<string> GetAccessTokenAsync(string serviceName, CancellationToken cancellationToken = default);

    /// <summary>
    /// 刷新访问令牌
    /// </summary>
    /// <param name="serviceName">服务名称</param>
    /// <param name="cancellationToken">取消令牌</param>
    /// <returns>新的访问令牌</returns>
    Task<string> RefreshTokenAsync(string serviceName, CancellationToken cancellationToken = default);

    /// <summary>
    /// 验证令牌有效性
    /// </summary>
    /// <param name="token">访问令牌</param>
    /// <param name="cancellationToken">取消令牌</param>
    /// <returns>令牌是否有效</returns>
    Task<bool> ValidateTokenAsync(string token, CancellationToken cancellationToken = default);
}